function doGET(url, params, callback) {
	var head = document.getElementsByTagName("head")[0];
	var script = document.createElement('script');
	script.type = "text/javascript";
	script.src = url + params + "&callback=" + callback;
	script.async = true;
	script.onload = script.onreadystatechange = function() {
		if (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") {
			try {
				callback();
			} catch (e) {
			}
			script.onload = script.onreadystatechange = null;
			if (head && script.parentNode) {
				head.removeChild(script);
			}
			script = undefined;
		}
	}
	head.appendChild(script);
}
var getIp_callback = function() {
	document.getElementById("ip_src").value = returnCitySN.cip;
	queryip();
}
function getIp() {
	doGET("https://pv.sohu.com/cityjson", "", getIp_callback);
}
var fanyi_callback = function(data) {
	var fanyi_dst = document.getElementById("fanyi_dst");
	fanyi_dst.style.borderColor = "green";
	fanyi_dst.value = data;
}
function fanyi() {
	var fanyi_url = document.getElementById("fanyi_url").value;
	var fanyi_text = document.getElementById("fanyi_text").value;
	var fanyi_dst = document.getElementById("fanyi_dst");
	fanyi_dst.style.borderColor = "red";
	fanyi_dst.value = "";
	var params = "?from=auto&to=auto&text=" + fanyi_text;
	doGET(fanyi_url, params, "fanyi_callback");
}
function queryip_callback(data) {
	var ip_addr = document.getElementById("ip_addr");
	ip_addr.style.borderColor = "green";
	ip_addr.value = data;
}
function queryip() {
	var ip_url = document.getElementById("ip_url").value;
	var ip_src = document.getElementById("ip_src").value;
	var ip_addr = document.getElementById("ip_addr");
	ip_addr.style.borderColor = "red";
	ip_addr.value = "";
	var params = "?ip=" + ip_src;
	doGET(ip_url, params, "queryip_callback");
}
function queryex_callback(data) {
	var json = eval('(' + data + ')');
	var ex_info = document.getElementById("ex_info");
	ex_info.style.borderColor = "green";
	var info = "快递公司：" + json.exName + " 电话：" + json.exTel + "\n";
	for (var i = 0; i < json.data.length; i++) {
		info += json.data[i].time + "\n" + json.data[i].context + "\n";
	}
	ex_info.value = info;
}
function queryex() {
	var ex_url = document.getElementById("ex_url").value;
	var ex_num = document.getElementById("ex_num").value;
	var ex_info = document.getElementById("ex_info");
	ex_info.style.borderColor = "red";
	ex_info.value = "";
	var params = "?exNum=" + ex_num;
	doGET(ex_url, params, "queryex_callback");
}